<template>
  <div>
      <button @click="fun('d1')">点我去d1</button>
      <button @click="fun('d2')">点我去d2</button>
      <keep-alive>
          <component :is="demo"></component>
      </keep-alive>
      <h4>keep-alive有两种属性，include（缓存那个），exclude（不想缓存那个），两个狗子函数，activated:进入到被keep-alive管理的组件时触发，deactivated:离开管理的组件时触发</h4>
  </div>
</template>

<script>
import D1 from "./d1.vue"
import D2 from "./d2.vue"

export default {
    components:{
        D1,D2
    },
   methods:{
        fun(data){
            this.demo=data
    }
   },
   data(){
       return{
           demo:"D2"
       }
   }
}
</script>

<style>

</style>